<template>
  <div v-if="show" class="modal-mask">
    <div class="modal-wrapper">
      <div class="modal-container">
        <button class="modal-close" @click="handleClose" aria-label="关闭弹窗">×</button>
        <h3>{{ title }}</h3>
        <p>{{ message }}<br>{{ countdownSeconds }}s后跳转原界面</p>
        <div class="modal-footer">
          <button class="btn btn-primary" @click="handleConfirm">确认</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'FormModal',
  props: {
    show: {
      type: Boolean,
      default: false
    },
    title: {
      type: String,
      default: '操作成功'
    },
    message: {
      type: String,
      default: '操作成功。'
    },
    countdownSeconds: {
      type: Number,
      default: 5
    }
  },
  methods: {
    handleClose() {
      this.$emit('close')
    },
    handleConfirm() {
      this.$emit('confirm')
    }
  }
}
</script>

<style scoped>
@import '../assets/css/common.css';
</style>
